<template>
    <a-select :value="modelValue" :options="options" @change="handleChange" :field-names="{ label: 'title', value: 'id' }" placeholder="请选择部门" />
</template>

<script setup lang="ts">
import { getDepartmentList } from '@/api/system/organize/department'
const props = defineProps<{
    modelValue: string | number,
    mode?: 'multiple' | 'tags' | 'combobox'
}>()

const options = ref([])
const emit = defineEmits(['update:modelValue'])
onMounted(async () => {
    const res = await getDepartmentList()
    options.value = res.lists
})

const handleChange = (value: string | number | null) => {
    emit('update:modelValue', value || '')
}

</script>

